package leetcode.code1749;

import leetcode.IDebug;

public class Solution implements IDebug {

	public int maxAbsoluteSum(int[] nums) {
		long max = Math.max(nums[0], 0);
		long min = Math.min(nums[0], 0);
		long sum = 0;
		long ans = Integer.MIN_VALUE;
		for (int i = 0; i < nums.length; i++) {
			sum += nums[i];
			long cur = Math.max(Math.abs(sum - max), Math.abs(sum - min));
			ans = Math.max(cur, ans);
			max = Math.max(max, sum);
			min = Math.min(min, sum);
		}
		return (int) ans;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
